home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / SoundComponents.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  12.5 KB  |  542 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        SoundComponents.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__SOUNDCOMPONENTS__') = 'UNDEFINED' THEN
  18. __SOUNDCOMPONENTS__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
  27.     include 'Components.a'
  28.     ENDIF
  29. ;        include 'MixedMode.a'                                        ;
  30.  
  31.     IF &TYPE('__SOUND__') = 'UNDEFINED' THEN
  32.     include 'Sound.a'
  33.     ENDIF
  34. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. ; constants
  36. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37.  
  38. ;sound component set/get info selectors
  39. siVolume                        EQU        'volu'
  40. siHardwareVolume                EQU        'hvol'
  41. siSpeakerVolume                    EQU        'svol'
  42. siHeadphoneVolume                EQU        'pvol'
  43. siHardwareVolumeSteps            EQU        'hstp'
  44. siHeadphoneVolumeSteps            EQU        'hdst'
  45. siHardwareMute                    EQU        'hmut'
  46. siSpeakerMute                    EQU        'smut'
  47. siHeadphoneMute                    EQU        'pmut'
  48. siRateMultiplier                EQU        'rmul'
  49. siQuality                        EQU        'qual'
  50. ;format types
  51. kOffsetBinary                    EQU        'raw '
  52. kTwosComplement                    EQU        'twos'
  53. kMACE3Compression                EQU        'MAC3'
  54. kMACE6Compression                EQU        'MAC6'
  55.  
  56. ;quality flags
  57. ;use interpolation in rate conversion
  58. kBestQuality                    EQU        (1 << 0)
  59.  
  60. ;useful bit masks
  61. kInputMask                        EQU        $000000FF            ;masks off input bits
  62. kOutputMask                        EQU        $0000FF00            ;masks off output bits
  63. kOutputShift                    EQU        8                    ;amount output bits are shifted
  64. kActionMask                        EQU        $00FF0000            ;masks off action bits
  65. kSoundComponentBits                EQU        $00FFFFFF
  66.  
  67. ;SoundComponentPlaySourceBuffer action flags
  68. kSourcePaused                    EQU        (1 << 0)
  69. kPassThrough                    EQU        (1 << 16)
  70. kNoSoundComponentChain            EQU        (1 << 17)
  71. ;flags for OpenMixerSoundComponent
  72. kNoMixing                        EQU        (1 << 0)            ;don't mix source
  73. kNoSampleRateConversion            EQU        (1 << 1)            ;don't convert sample rate (i.e. 11 kHz -> 22 kHz)
  74. kNoSampleSizeConversion            EQU        (1 << 2)            ;don't convert sample size (i.e. 16 -> 8)
  75. kNoSampleFormatConversion        EQU        (1 << 3)            ;don't convert sample format (i.e. 'twos' -> 'raw ')
  76. kNoChannelConversion            EQU        (1 << 4)            ;don't convert stereo/mono
  77. kNoDecompression                EQU        (1 << 5)            ;don't decompress (i.e. 'MAC3' -> 'raw ')
  78. kNoVolumeConversion                EQU        (1 << 6)            ;don't apply volume
  79. kNoRealtimeProcessing            EQU        (1 << 7)            ;won't run at interrupt time
  80.  
  81. ;Audio Component constants
  82. ;Values for whichChannel parameter
  83. audioAllChannels                EQU        0                    ;All channels (usually interpreted as both left and right)
  84. audioLeftChannel                EQU        1                    ;Left channel
  85. audioRightChannel                EQU        2                    ;Right channel
  86. ;Values for mute parameter
  87. audioUnmuted                    EQU        0                    ;Device is unmuted
  88. audioMuted                        EQU        1                    ;Device is muted
  89. ;Capabilities flags definitions
  90. audioDoesMono                    EQU        (1 << 0)            ;Device supports mono output
  91. audioDoesStereo                    EQU        (1 << 1)            ;Device supports stereo output
  92. audioDoesIndependentChannels    EQU        (1 << 2)            ;Device supports independent software control of each channel
  93.  
  94. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. ; typedefs
  96. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. ;ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,
  98. ;with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375
  99. SoundComponentData         RECORD    0
  100. flags                     ds.l    1
  101. format                     ds.l    1
  102. numChannels                 ds.w    1
  103. sampleSize                 ds.w    1
  104. sampleRate                 ds.l    1
  105. sampleCount                 ds.l    1
  106. buffer                     ds.l    1
  107. reserved                 ds.l    1
  108. sizeof                     EQU    28
  109.                         ENDR
  110.  
  111. SoundParamBlock         RECORD    0
  112. recordSize                 ds.l    1                                    ;size of this record in bytes
  113. desc                     ds        SoundComponentData                    ;description of sound buffer
  114. rateMultiplier             ds.l    1                                    ;rate multiplier to apply to sound
  115. leftVolume                 ds.w    1                                    ;volumes to apply to sound
  116. rightVolume                 ds.w    1
  117. quality                     ds.l    1                                    ;quality to apply to sound
  118. filter                     ds.l    1                                    ;filter to apply to sound
  119. moreRtn                     ds.l    1                                    ;routine to call to get more data
  120. completionRtn             ds.l    1                                    ;routine to call when buffer is complete
  121. refCon                     ds.l    1                                    ;user refcon
  122. result                     ds.w    1                                    ;result
  123. sizeof                     EQU    62
  124.                         ENDR
  125.  
  126. AudioInfo                 RECORD    0
  127. capabilitiesFlags         ds.l    1                                    ;Describes device capabilities
  128. reserved                 ds.l    1                                    ;Reserved by Apple
  129. numVolumeSteps             ds.w    1                                    ;Number of significant increments between min and max volume
  130. sizeof                     EQU    10
  131.                         ENDR
  132.  
  133. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134. ; functions for sound components
  135. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  136. ;Sound Component dispatch selectors
  137.  
  138. ;these calls cannot be delegated
  139. kSoundComponentInitOutputDeviceSelect EQU        1
  140. kSoundComponentSetSourceSelect    EQU        2
  141. kSoundComponentGetSourceSelect    EQU        3
  142. kSoundComponentGetSourceDataSelect EQU        4
  143. kSoundComponentSetOutputSelect    EQU        5
  144. kDelegatedSoundComponentSelectors EQU        $0100                ;first selector that can be delegated up the chain
  145. ;these calls can be delegated and have own range
  146. kSoundComponentAddSourceSelect    EQU        kDelegatedSoundComponentSelectors + 1
  147. kSoundComponentRemoveSourceSelect EQU        kDelegatedSoundComponentSelectors + 2
  148. kSoundComponentGetInfoSelect    EQU        kDelegatedSoundComponentSelectors + 3
  149. kSoundComponentSetInfoSelect    EQU        kDelegatedSoundComponentSelectors + 4
  150. kSoundComponentStartSourceSelect EQU        kDelegatedSoundComponentSelectors + 5
  151. kSoundComponentStopSourceSelect    EQU        kDelegatedSoundComponentSelectors + 6
  152. kSoundComponentPauseSourceSelect EQU        kDelegatedSoundComponentSelectors + 7
  153. kSoundComponentPlaySourceBufferSelect EQU        kDelegatedSoundComponentSelectors + 8
  154.  
  155. ;Audio Component selectors
  156. kAudioGetVolumeSelect            EQU        0
  157. kAudioSetVolumeSelect            EQU        1
  158. kAudioGetMuteSelect                EQU        2
  159. kAudioSetMuteSelect                EQU        3
  160. kAudioSetToDefaultsSelect        EQU        4
  161. kAudioGetInfoSelect                EQU        5
  162. kAudioGetBassSelect                EQU        6
  163. kAudioSetBassSelect                EQU        7
  164. kAudioGetTrebleSelect            EQU        8
  165. kAudioSetTrebleSelect            EQU        9
  166. kAudioGetOutputDeviceSelect        EQU        10
  167. kAudioMuteOnEventSelect            EQU        129
  168.  
  169. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. ; Sound Manager 3.0 utilities
  171.     IF GENERATING68K THEN
  172.         Macro
  173.         _OpenMixerSoundComponent
  174.             dc.w     $203C
  175.             dc.w     $0614
  176.             dc.w     $0018
  177.             dc.w     $A800
  178.         EndM
  179.     ELSE
  180.         IMPORT    OpenMixerSoundComponent
  181.     ENDIF
  182.  
  183.     IF GENERATING68K THEN
  184.         Macro
  185.         _CloseMixerSoundComponent
  186.             dc.w     $203C
  187.             dc.w     $0218
  188.             dc.w     $0018
  189.             dc.w     $A800
  190.         EndM
  191.     ELSE
  192.         IMPORT    CloseMixerSoundComponent
  193.     ENDIF
  194.  
  195. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196. ; basic sound component functions
  197.     IF GENERATING68K THEN
  198.         Macro
  199.         _SoundComponentInitOutputDevice
  200.             dc.w     $2F3C
  201.             dc.w     $0000
  202.             dc.w     $0000
  203.             moveq    #0,d0
  204.             dc.w     $A82A
  205.         EndM
  206.     ELSE
  207.         IMPORT    SoundComponentInitOutputDevice
  208.     ENDIF
  209.  
  210.     IF GENERATING68K THEN
  211.         Macro
  212.         _SoundComponentSetSource
  213.             dc.w     $2F3C
  214.             dc.w     $0000
  215.             dc.w     $0000
  216.             moveq    #0,d0
  217.             dc.w     $A82A
  218.         EndM
  219.     ELSE
  220.         IMPORT    SoundComponentSetSource
  221.     ENDIF
  222.  
  223.     IF GENERATING68K THEN
  224.         Macro
  225.         _SoundComponentGetSource
  226.             dc.w     $2F3C
  227.             dc.w     $0000
  228.             dc.w     $0000
  229.             moveq    #0,d0
  230.             dc.w     $A82A
  231.         EndM
  232.     ELSE
  233.         IMPORT    SoundComponentGetSource
  234.     ENDIF
  235.  
  236.     IF GENERATING68K THEN
  237.         Macro
  238.         _SoundComponentGetSourceData
  239.             dc.w     $2F3C
  240.             dc.w     $0000
  241.             dc.w     $0000
  242.             moveq    #0,d0
  243.             dc.w     $A82A
  244.         EndM
  245.     ELSE
  246.         IMPORT    SoundComponentGetSourceData
  247.     ENDIF
  248.  
  249.     IF GENERATING68K THEN
  250.         Macro
  251.         _SoundComponentSetOutput
  252.             dc.w     $2F3C
  253.             dc.w     $0000
  254.             dc.w     $0000
  255.             moveq    #0,d0
  256.             dc.w     $A82A
  257.         EndM
  258.     ELSE
  259.         IMPORT    SoundComponentSetOutput
  260.     ENDIF
  261.  
  262. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  263. ; junction methods for the mixer, must be called at non-interrupt level
  264.     IF GENERATING68K THEN
  265.         Macro
  266.         _SoundComponentAddSource
  267.             dc.w     $2F3C
  268.             dc.w     $0000
  269.             dc.w     $0101
  270.             moveq    #0,d0
  271.             dc.w     $A82A
  272.         EndM
  273.     ELSE
  274.         IMPORT    SoundComponentAddSource
  275.     ENDIF
  276.  
  277.     IF GENERATING68K THEN
  278.         Macro
  279.         _SoundComponentRemoveSource
  280.             dc.w     $2F3C
  281.             dc.w     $0000
  282.             dc.w     $0102
  283.             moveq    #0,d0
  284.             dc.w     $A82A
  285.         EndM
  286.     ELSE
  287.         IMPORT    SoundComponentRemoveSource
  288.     ENDIF
  289.  
  290. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  291. ; info methods
  292.     IF GENERATING68K THEN
  293.         Macro
  294.         _SoundComponentGetInfo
  295.             dc.w     $2F3C
  296.             dc.w     $0002
  297.             dc.w     $0103
  298.             moveq    #0,d0
  299.             dc.w     $A82A
  300.         EndM
  301.     ELSE
  302.         IMPORT    SoundComponentGetInfo
  303.     ENDIF
  304.  
  305.     IF GENERATING68K THEN
  306.         Macro
  307.         _SoundComponentSetInfo
  308.             dc.w     $2F3C
  309.             dc.w     $0002
  310.             dc.w     $0104
  311.             moveq    #0,d0
  312.             dc.w     $A82A
  313.         EndM
  314.     ELSE
  315.         IMPORT    SoundComponentSetInfo
  316.     ENDIF
  317.  
  318. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  319. ; control methods
  320.     IF GENERATING68K THEN
  321.         Macro
  322.         _SoundComponentStartSource
  323.             dc.w     $2F3C
  324.             dc.w     $0000
  325.             dc.w     $0105
  326.             moveq    #0,d0
  327.             dc.w     $A82A
  328.         EndM
  329.     ELSE
  330.         IMPORT    SoundComponentStartSource
  331.     ENDIF
  332.  
  333.     IF GENERATING68K THEN
  334.         Macro
  335.         _SoundComponentStopSource
  336.             dc.w     $2F3C
  337.             dc.w     $0000
  338.             dc.w     $0106
  339.             moveq    #0,d0
  340.             dc.w     $A82A
  341.         EndM
  342.     ELSE
  343.         IMPORT    SoundComponentStopSource
  344.     ENDIF
  345.  
  346.     IF GENERATING68K THEN
  347.         Macro
  348.         _SoundComponentPauseSource
  349.             dc.w     $2F3C
  350.             dc.w     $0000
  351.             dc.w     $0107
  352.             moveq    #0,d0
  353.             dc.w     $A82A
  354.         EndM
  355.     ELSE
  356.         IMPORT    SoundComponentPauseSource
  357.     ENDIF
  358.  
  359.     IF GENERATING68K THEN
  360.         Macro
  361.         _SoundComponentPlaySourceBuffer
  362.             dc.w     $2F3C
  363.             dc.w     $0002
  364.             dc.w     $0108
  365.             moveq    #0,d0
  366.             dc.w     $A82A
  367.         EndM
  368.     ELSE
  369.         IMPORT    SoundComponentPlaySourceBuffer
  370.     ENDIF
  371.  
  372. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. ; interface for Audio Components
  374. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  375. ;Volume is described as a value between 0 and 1, with 0 indicating minimum
  376. ;  volume and 1 indicating maximum volume; if the device doesn't support
  377. ;  software control of volume, then a value of unimpErr is returned, indicating
  378. ;  that these functions are not supported by the device
  379.     IF GENERATING68K THEN
  380.         Macro
  381.         _AudioGetVolume
  382.             dc.w     $2F3C
  383.             dc.w     $0000
  384.             dc.w     $0000
  385.             moveq    #0,d0
  386.             dc.w     $A82A
  387.         EndM
  388.     ELSE
  389.         IMPORT    AudioGetVolume
  390.     ENDIF
  391.  
  392.     IF GENERATING68K THEN
  393.         Macro
  394.         _AudioSetVolume
  395.             dc.w     $2F3C
  396.             dc.w     $0000
  397.             dc.w     $0000
  398.             moveq    #0,d0
  399.             dc.w     $A82A
  400.         EndM
  401.     ELSE
  402.         IMPORT    AudioSetVolume
  403.     ENDIF
  404.  
  405. ;If the device doesn't support software control of mute, then a value of unimpErr is
  406. ;returned, indicating that these functions are not supported by the device
  407.     IF GENERATING68K THEN
  408.         Macro
  409.         _AudioGetMute
  410.             dc.w     $2F3C
  411.             dc.w     $0000
  412.             dc.w     $0000
  413.             moveq    #0,d0
  414.             dc.w     $A82A
  415.         EndM
  416.     ELSE
  417.         IMPORT    AudioGetMute
  418.     ENDIF
  419.  
  420.     IF GENERATING68K THEN
  421.         Macro
  422.         _AudioSetMute
  423.             dc.w     $2F3C
  424.             dc.w     $0000
  425.             dc.w     $0000
  426.             moveq    #0,d0
  427.             dc.w     $A82A
  428.         EndM
  429.     ELSE
  430.         IMPORT    AudioSetMute
  431.     ENDIF
  432.  
  433. ;AudioSetToDefaults causes the associated device to reset its volume and mute values
  434. ;(and perhaps other characteristics, e.g. attenuation) to "factory default" settings
  435.     IF GENERATING68K THEN
  436.         Macro
  437.         _AudioSetToDefaults
  438.             dc.w     $2F3C
  439.             dc.w     $0000
  440.             dc.w     $0000
  441.             moveq    #0,d0
  442.             dc.w     $A82A
  443.         EndM
  444.     ELSE
  445.         IMPORT    AudioSetToDefaults
  446.     ENDIF
  447.  
  448. ;This routine is required; it must be implemented by all audio components
  449.     IF GENERATING68K THEN
  450.         Macro
  451.         _AudioGetInfo
  452.             dc.w     $2F3C
  453.             dc.w     $0000
  454.             dc.w     $0000
  455.             moveq    #0,d0
  456.             dc.w     $A82A
  457.         EndM
  458.     ELSE
  459.         IMPORT    AudioGetInfo
  460.     ENDIF
  461.  
  462.     IF GENERATING68K THEN
  463.         Macro
  464.         _AudioGetBass
  465.             dc.w     $2F3C
  466.             dc.w     $0000
  467.             dc.w     $0000
  468.             moveq    #0,d0
  469.             dc.w     $A82A
  470.         EndM
  471.     ELSE
  472.         IMPORT    AudioGetBass
  473.     ENDIF
  474.  
  475.     IF GENERATING68K THEN
  476.         Macro
  477.         _AudioSetBass
  478.             dc.w     $2F3C
  479.             dc.w     $0000
  480.             dc.w     $0000
  481.             moveq    #0,d0
  482.             dc.w     $A82A
  483.         EndM
  484.     ELSE
  485.         IMPORT    AudioSetBass
  486.     ENDIF
  487.  
  488.     IF GENERATING68K THEN
  489.         Macro
  490.         _AudioGetTreble
  491.             dc.w     $2F3C
  492.             dc.w     $0000
  493.             dc.w     $0000
  494.             moveq    #0,d0
  495.             dc.w     $A82A
  496.         EndM
  497.     ELSE
  498.         IMPORT    AudioGetTreble
  499.     ENDIF
  500.  
  501.     IF GENERATING68K THEN
  502.         Macro
  503.         _AudioSetTreble
  504.             dc.w     $2F3C
  505.             dc.w     $0000
  506.             dc.w     $0000
  507.             moveq    #0,d0
  508.             dc.w     $A82A
  509.         EndM
  510.     ELSE
  511.         IMPORT    AudioSetTreble
  512.     ENDIF
  513.  
  514.     IF GENERATING68K THEN
  515.         Macro
  516.         _AudioGetOutputDevice
  517.             dc.w     $2F3C
  518.             dc.w     $0000
  519.             dc.w     $0000
  520.             moveq    #0,d0
  521.             dc.w     $A82A
  522.         EndM
  523.     ELSE
  524.         IMPORT    AudioGetOutputDevice
  525.     ENDIF
  526.  
  527. ;This is routine is private to the AudioVision component.  It enables the watching of the mute key.
  528.     IF GENERATING68K THEN
  529.         Macro
  530.         _AudioMuteOnEvent
  531.             dc.w     $2F3C
  532.             dc.w     $0000
  533.             dc.w     $0029
  534.             moveq    #0,d0
  535.             dc.w     $A82A
  536.         EndM
  537.     ELSE
  538.         IMPORT    AudioMuteOnEvent
  539.     ENDIF
  540.  
  541.     ENDIF ; __SOUNDCOMPONENTS__
  542.